package org.example.secondkill.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.secondkill.domain.User;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserDao {
    // 用户注册
    @Insert("insert into t_user(nickname, password) values(#{nickname}, #{password})")
    Integer register(@Param("nickname") String nickname, @Param("password") String password);

    // 根据用户id查询用户
    @Select("select * from t_user where id=#{userId}")
    User selectById(@Param("userId") long userId);

    // 根据username查询用户
    @Select("select * from t_user where nickname=#{nickname}")
    User selectByNickname(@Param("nickname") String nickname);
}
